﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using T.FAS.Runtime.Base.Entity;

namespace T.FAS.Runtime.Metadata.Entity
{
    /// <summary>
    /// Action方法参数
    /// </summary>
    [Serializable]
    public class ActionMetaDataMethodParam
    {
        public string ID { get; set; }
        public string ActionMetaDataID { get; set; }
        public string Code { get; set; }
        public string Name { get; set; }
        public int SortOrder { get; set; }
        /// <summary>
        /// 参数类型,出参或入参
        /// </summary>
        public ParamType ParamType { get; set; }
        public ParamSourceType ParamSourceType { get; set; }
        public string SourceID { get; set; }
        public string SourceName { get; set; }
        /// <summary>
        /// 参数程序集信息
        /// </summary>
        public string ParamAssembly { get; set; }
        /// <summary>
        /// 参数值类型
        /// </summary>
        public string ParamValueType { get; set; }
        /// <summary>
        /// 是否集合
        /// True的时候数据为List，False的是单条数据
        /// </summary>
        public bool IsList { get; set; }
        public string DefaultValue { get; set; }
        /// <summary>
        /// 变量实际值
        /// </summary>
        public object ParamValue { get; set; }
        public string Description { get; set; }
        /// <summary>
        /// 是否系统默认参数
        /// </summary>
        public bool IsSysDefault { get; set; }
        /// <summary>
        /// 是否是动态参数条件，用于Advance的SQLAction
        /// </summary>
        public bool IsDynamic { get; set; }
        /// <summary>
        /// 是否可为空
        /// </summary>
        public bool IsAllowNull { get; set; }
        public string Ext1 { get; set; }
        public string Ext2 { get; set; }
        public string Ext3 { get; set; }
        public DateTime CreateTime { get; set; }
        public string Creator { get; set; }
        public DateTime LastModifyTime { get; set; }
        public string LastModifier { get; set; }
        public DataType SysDataType
        {
            get
            {
                return DataTypeUtil.ConvertToElementDataType(this.ParamValueType);
            }
        }
        public ActionMetaDataMethodParam Copy()
        {
            return new ActionMetaDataMethodParam()
            {
                ID = this.ID,
                ActionMetaDataID = this.ActionMetaDataID,
                Code = this.Code,
                Name = this.Name,
                SortOrder = this.SortOrder,
                ParamType = this.ParamType,
                ParamSourceType =this.ParamSourceType,
                SourceID = this.SourceID,
                SourceName = this.SourceName,
                ParamAssembly= this.ParamAssembly,
                ParamValueType = this.ParamValueType,
                DefaultValue = this.DefaultValue,
                Description = this.Description,
                IsSysDefault = this.IsSysDefault,
                IsDynamic = this.IsDynamic,
                IsAllowNull = this.IsAllowNull,
                Ext1 = this.Ext1,
                Ext2 = this.Ext2,
                Ext3 = this.Ext3,
                CreateTime = this.CreateTime,
                Creator = this.Creator,
                LastModifyTime= this.LastModifyTime,
                LastModifier = this.LastModifier
            };
        }
    }
}
